package com.yuandian.customer.perception.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuandian.api.business_monitor.vo.BusinessDetailVo;
import com.yuandian.api.customer_perception.po.BusinessDetailParams;
import com.yuandian.constant.ConfigKey;
import com.yuandian.customer.perception.mapper.BusinessDetailMapper;
import com.yuandian.customer.perception.service.IBusinessDetailService;
import com.yuandian.customer.perception.util.RemoteQueryUtil;
import com.yuandian.utils.PageDataInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 说明：业务明细service实现
 *
 * @Author yanjun
 * @Date 2021/3/18 13:16
 */
@Slf4j
@Service
public class BusinessDetailServiceImpl implements IBusinessDetailService {

	@Autowired
	private BusinessDetailMapper businessDetailMapper;

	@Autowired
	private RemoteQueryUtil remoteQueryUtil;


	/**
	 * 查询业务明细列表
	 *
	 * @param params 业务明细请求参数
	 * @return 通用分页对象
	 */
	@Override
	public PageDataInfo queryBusinessDetailList(BusinessDetailParams params) {
		Page<BusinessDetailVo> page = new Page<>(params.getPageNum(), params.getPageSize());
		// 获取参数
		String queryNotNullFlag = "";
		try {
			queryNotNullFlag = remoteQueryUtil.queryBasicServiceDate(ConfigKey.QUERY_NOT_NULL_FLAG);
		} catch (Exception e) {
			queryNotNullFlag = "false";
			log.warn("实时指标-数据上报-远程调用-基础服务-获取公共参数配置-失败-{}参数采用默认值：'false'", ConfigKey.QUERY_NOT_NULL_FLAG);
		}
		params.setQueryNotNullFlag(queryNotNullFlag);
		params.setDoing(0);

		// 查询数据
		List<BusinessDetailVo> businessDetailVos = businessDetailMapper.queryBusinessDetailList(page, params);

		return new PageDataInfo(page, businessDetailVos);
	}


}
